package com.chenglai.seckill.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 类描述：MQ服务端
 *
 * @author rjh
 * @date 2023/11/7 9:48
 */
@Component
public class MqServer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //测试发送消息
    public void sendMessage(String message) {
        System.out.println("发送消息：" + message);
        rabbitTemplate.convertAndSend("seckillExchange", "seckill.message", message);
    }

    //order下单
    public void sendSeckillMessage(Map<String, Object> data) {
        System.out.println("发送秒杀消息！");
        rabbitTemplate.convertAndSend("seckillExchange", "seckill.message", data);
    }

    //团购
    public void sendGroupOnMessage(Map<String, Object> map) {
        System.out.println("发送团购消息");
        rabbitTemplate.convertAndSend("seckillExchange", "groupNo.message", map);
    }

}
